#!/bin/sh
#
# /etc/rc.d/rc.policyd
#
# start/stop/restart policy daemon

# The PIDFILE is setup in the config file. Default is /var/run/policyd.pid
# if you change the location in the config file then it **needs** to be changed here too.
PIDFILE="/var/run/policyd.pid"
CONFIG="/etc/policyd.conf"

policyd_start() {
  if [ -x /etc/rc.d/rc.policyd ]; then
    echo "Starting Policy daemon"
    /usr/bin/policyd -c $CONFIG
  fi
}

policyd_stop() {
  echo "Stopping Policy daemon"
  /bin/kill $(cat $PIDFILE)
  rm -f $PIDFILE
}

policyd_restart() {
  policyd_stop
  sleep 2
  policyd_start
}

case "$1" in
'start')
	policyd_start
  ;;
'stop')
	policyd_stop
  ;;
'restart')
	policyd_restart
  ;;
'*')
	echo "USAGE: $0 start|stop|restart"
	exit 1
  ;;
esac
